#include <iostream>
#include <unordered_set>
using namespace std;
//本题使用了滑动数组的方式，利用set存储已经访问过的char值
class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int size=s.length();
        unordered_set<char> x;
        int ans=0;
        int fast=0;

        for(int i=0;i<size;i++){
            if(i!=0)x.erase(s[i-1]);
            while(fast<size&&!x.count(s[fast])){
                x.insert(s[fast]);
                fast++;
            }
            ans=max(ans,fast-i);
        }
        return ans;
    }
};
int main(){
    string s="";
    Solution solution;
    cout<<solution.lengthOfLongestSubstring(s);
}